<?
@session_start();
require_once("conn.php");
if($_SESSION["ids"] != "" && $_SESSION["usernames"] != ""){
	echo "<script>location.href='index.php';</script>";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"[]>
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title>Purchase System</title>
	<!--[if IE 6]><link rel="stylesheet" href="style.ie6.css" type="text/css" media="screen" /><![endif]-->
	<!--[if IE 7]><link rel="stylesheet" href="style.ie7.css" type="text/css" media="screen" /><![endif]-->
	<script type="text/javascript" src="scripts/jquery-1.6.2.min.js"></script>
	<script type="text/javascript" src="scripts/jquery.dataTables.min.js"></script>
	<script type="text/javascript" src="scripts/jquery-ui-1.8.7.custom.min.js"></script>

		<!-- custom -->
	<script type="text/javascript" src="scripts/purchase.js"></script>
	<script type="text/javascript" src="scripts/jquery.autocomplete.js"></script>
	<script type="text/javascript">
		$().ready(function() {
			$("#username").focus();
		});
	</script>
	<link rel="stylesheet" href="style.css" type="text/css" media="screen" />
	<link rel="stylesheet" type="text/css" href="tables.css"/>
	<link rel="stylesheet" type="text/css" href="stylesheets/flick/jquery-ui-1.8.7.custom.css" />
	<link rel="stylesheet" href="css/jquery.autocomplete.css" type="text/css" />
	<style type="text/css">
		body,input,select{font-family:Zawgyi-one,Zawgyi1;padding:0px;margin:0px;font-size:20px;}
		@font-face{font-family: Zawgyi-One;font-style: normal;font-weight: normal;src: url('http://www.mysteryzillion.com/eot/ZAWGYIO3.eot');}
		@font-face{font-family: Zawgyi-One;font-style: normal;font-weight: 700;src: url('http://www.mysteryzillion.com/eot/ZAWGYIO2.eot');}
		@font-face{font-family: Zawgyi-One;font-style: oblique;font-weight: normal;src: url('http://www.mysteryzillion.com/eot/ZAWGYIO1.eot');}
		@font-face{font-family: Zawgyi-One;font-style: oblique;font-weight: 700;src: url('http://www.mysteryzillion.com/eot/ZAWGYIO0.eot');}

		.art-post .layout-item-0 { padding-right: 10px;padding-left: 10px; }
		.ie7 .art-post .art-layout-cell {border:none !important; padding:0 !important; }
		.ie6 .art-post .art-layout-cell {border:none !important; padding:0 !important; }

		.images{border:0px;}	
		.center{width:200px;}
		li{list-style-type:none;}
		.required{color:red;padding-left:10px;font-weight:bold;}
		.input_require{background-color: #FFFF99;}
		#or_list{border:1px solid #ccc;border-collapse:collapse;display:none;}
		#main_panel{border: 1px solid #ccc;min-height:400px;padding:5px;}
		.aQ{text-align:left;color:red;font-weight:bold;}
		.a{text-align:left;}
		.b{text-align:center;}
		.c{text-align:center;}
	</style>
</head>
<body>
<div id="art-main">
    <div class="cleared reset-box"></div>
    <div class="art-header">
        <div class="art-header-position">
            <div class="art-header-wrapper">
                <div class="cleared reset-box"></div>
                <div class="art-header-inner">
					<div class="art-headerobject"></div>
					<div class="art-logo">
						<h1 class="art-logo-name">Purchase System</h1>
					</div>
                </div>
            </div>
        </div>
    </div>
    <div class="cleared reset-box"></div>
    <div class="art-box art-sheet">
        <div class="art-box-body art-sheet-body">
            <div class="art-layout-wrapper">
                <div class="art-content-layout">
                    <div class="art-content-layout-row">
                        <?
							require_once("conn.php");
							if($_POST["login2"] != ""){

								$user = $_POST["username"];
								$pass = $_POST["password"];

								if($user != "" && $pass != ""){
									$sql = "select a.id as id,username,groups from member as a join pch_user_access as b on a.id=b.user_id WHERE username='$user' AND password=md5('$pass');";
									
									$query = mysql_query($sql);
									$result = mysql_fetch_assoc($query);
									if(mysql_num_rows($query) > 0){
										$_SESSION["ids"] = $result["id"];
										$_SESSION["groups"] = $result["groups"];
										$_SESSION["usernames"] = $result["username"];
										$_SESSION["language"] = "TH";
										echo "<script>location.href='index.php';</script>";
										//echo $_SESSION["ids"]."<:>".$_SESSION["usernames"];
									}else{
										echo "<script>alert(\"Login Error\");location.href=\"login.php\";</script>";
									}
								}

							}else{
							?>
								<table border="0" style="height:600px;" align="center" cellpadding="0" cellspacing="0">
									<tr>
										<td align="center">
											<div align="center">
												<form id="login" name="login" method="post" action="login.php?rand=<?=rand();?>"> 
													<table border="0" cellspacing="0" cellpadding="0" align="center">
														<tr>					
															<td height="200" align="left" valign="top" background="images/bg-login.gif">
																<table border="0" cellspacing="0" cellpadding="0">
																	<tr>
																		<td>&nbsp;</td>
																	</tr>
																	<tr>
																		<td width="">&nbsp;</td>
																	</tr>
																	<tr>
																		<td align="left">Username :</td>
																	</tr>
																	<tr>
																		<td align="left">
																			<label>
																				<input name="username" type="text" id="username" style="width:150px;"/>
																			</label>
																		</td>
																	</tr>
																	<tr>
																		<td align="left" class="style_balnk2">Password :</td>
																	</tr>
																	<tr>
																		<td align="left">
																			<label>
																				<input name="password" type="password" style="width:150px;"/>
																			</label>
																		</td>
																	</tr>
																	<tr>
																		<td align="left">&nbsp;</td>
																	</tr>
																	<tr>
																		<td align="center" valign="middle">
																			<label>					   
																				<input type="submit" name="login2" id="login2" value="Login" style="width:100px;height:25px;"/>							 
																			</label>
																		</td>
																	</tr>
																</table>
															</td>
														</tr>
													</table>
												</form>
											</div>
										</td>
									</tr>
								</table>
							<?
								}
							?>
						<div class="cleared"></div>                        
                    </div>
                </div>
            </div>
            <div class="cleared"></div>
    		<div class="cleared"></div>
        </div>
    </div>
    <div class="art-footer">
        <div class="art-footer-body">
            <div class="art-footer-center">
                <div class="art-footer-wrapper">
                    <div class="art-footer-text">
						<p>Copyright © 2012. All Rights Reserved. Banraya Resort & Spa</p>
                        <div class="cleared"></div>
                    </div>
                </div>
            </div>
            <div class="cleared"></div>
        </div>
    </div>
    <div class="cleared"></div>
</div>
</body>
</html>